
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>${sessionScope.title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>管理员管理</cite></a>
              <a><cite>权限管理</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="/adminSystem/adminRuleList"  style="width:70%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">

            </div>
        </div>
    </form>
    <xblock>
        <%-- <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button>--%>
        <button class="layui-btn" onclick="rule_edit('新增按钮权限','/adminSystem/editAuthorizationButton?id=&parentid=${parentid}','600','400')"><i class="layui-icon">&#xe608;</i>添加</button>
    </xblock>


    <table class="layui-table">
        <thead>
        <tr>
            <th>
                ID
            </th>
            <th>
                权限url
            </th>
            <th>
                权限名称
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody id="x-link">
        <c:forEach items="${rec}" var="men" varStatus="ind">
            <tr>
                <td>
                        ${men.id}
                </td>
                <td>
                        ${men.url}
                </td>
                <td>
                        ${men.name}
                </td>
                <td class="td-manage">
                    <a title="编辑" href="javascript:;" onclick="rule_edit('编辑','/adminSystem/editAuthorizationButton?id=${men.id}&parentid=${parentid}','600','400')"
                       class="ml-5" style="text-decoration:none">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除" href="javascript:;" onclick="rule_del(this,'${men.id}')"
                       style="text-decoration:none">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

</div>
<script src="/admin/js/x-layui.js" charset="utf-8"></script>
<script src="/js/layui/layui.all.js" charset="utf-8"></script>

<script src="/admin/js/jquery.min.js" charset="utf-8"></script>
<script>
    /*****************分页********************************/






    /*form提交数据*/
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(/adminSystem/adminRuleList)', function(fromData){
        });
    });


    //以上模块根据需要引入

    //批量删除提交
    function delAll () {
        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }

    //-编辑
    function rule_edit (title,url,w,h) {
        x_admin_show(title,url,w,h);
    }

    /*删除*/
    function rule_del(obj,id){//删除权限
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.ajax({
                url:'/adminSystem/delPermission',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:{
                    id:id
                },
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){
                    /*console.log(xhr)
                     console.log('发送前')*/
                },
                success:function(data){
                    if (true == data){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else {
                        layer.msg('删除失败!',{icon:5,time:1000});
                    }
                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function(){
                    //console.log('结束')
                }
            })

        });
    }


</script>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
</fieldset>
<div id="fenye" style="text-align: center" ></div>
<script type="application/javascript">
    /*分页*/

</script>
</body>
</html>
